
import excel "anonymized1.xlsx", sheet("Limits+of+Extra-judicial_March+") firstrow case(lower)



** remove researcher generated observations
drop if status == "Survey Preview"


** remove duplicates 
duplicates tag responseid, generate(duplicate)
tab duplicate
drop if duplicate == 1

drop startdate-userlanguage

*** pre-treatment legitimacy
foreach var of varlist q2_1-q2_7{
	gen `var'2 = .
	replace `var'2 = 0 if `var' == "Strongly agree"
	replace `var'2 = 0 if `var' == "Strongly Agree"
	replace `var'2 = 1 if `var' == "Agree"
	replace `var'2 = 2 if `var' == "Neither agree nor disagree"
	replace `var'2 = 2 if `var' == "Neither Agree nor disagree"
	replace `var'2 = 3 if `var' == "Disagree"
	replace `var'2 = 4 if `var' == "Strongly disagree"
	replace `var'2 = 4 if `var' == "Strongly Disagree"
}
*
alpha q2_12-q2_72, gen(preLegit)

*** pre-treatment politicization
foreach var of varlist q4_1-q4_3{
	gen `var'2 = .
	replace `var'2 = 4 if `var' == "Strongly agree"
	replace `var'2 = 4 if `var' == "Strongly Agree"
	replace `var'2 = 3 if `var' == "Agree"
	replace `var'2 = 2 if `var' == "Neither agree nor disagree"
	replace `var'2 = 2 if `var' == "Neither Agree nor disagree"
	replace `var'2 = 1 if `var' == "Disagree"
	replace `var'2 = 0 if `var' == "Strongly disagree"
	replace `var'2 = 0 if `var' == "Strongly Disagree"
}
*
alpha q4_12-q4_32, gen(prePolit)

*** pre-treatment SC ideology
tab q6
gen preSCideo = . 
replace preSC = 1 if q6 == "Very liberal"
replace preSC = 2 if q6 == "Somewhat liberal"
replace preSC = 3 if q6 == "Moderate"
replace preSC = 4 if q6 == "Somewhat conservative"
replace preSC = 5 if q6 == "Very conservative"


*** feeling thermometers 
rename q50_1 romney
rename q50_18 oreilly
rename q50_19 cooper
rename q50_2 maddow
rename q50_3 schumer
rename q50_4 limbaugh

*** predispositions
gen pid = .
replace pid = 1 if q52 == "Democrat" & q56 == "Strong"
replace pid = 2 if q52 == "Democrat" & q56 == "Not very strong"
replace pid = 3 if q52 == "Independent" & q58 == "Democratic Party"
replace pid = 4 if q52 == "Independent" & q58 == "Neither"
replace pid = 5 if q52 == "Independent" & q58 == "Republican party"
replace pid = 6 if q52 == "Republican" & q54 == "Not very strong"
replace pid = 7 if q52 == "Republican" & q54 == "Strong"

tab q52
*** attention check
tab q79
drop if q79 != "I do not hold a government position"


*** ideology
gen ideo7 = . 
replace ideo7 = 1 if q72 == "Extremely liberal"
replace ideo7 = 2 if q72 == "Liberal"
replace ideo7 = 3 if q72 == "Slightly liberal"
replace ideo7 = 4 if q72 == "Moderate"
replace ideo7 = 5 if q72 == "Slightly conservative"
replace ideo7 = 6 if q72 == "Conservative"
replace ideo7 = 7 if q72 == "Extremely conservative"

gen ideo5 = ideo7
recode ideo5 1 = 1 2 = 2 3 = 2 4 = 3 5 = 4 6 = 4 7 = 5



*** post-treatment control
foreach var of varlist q119_1-q119_7{
	gen `var'2 = .
	replace `var'2 = 0 if `var' == "Strongly agree"
	replace `var'2 = 0 if `var' == "Strongly Agree"
	replace `var'2 = 1 if `var' == "Agree"
	replace `var'2 = 2 if `var' == "Neither agree nor disagree"
	replace `var'2 = 2 if `var' == "Neither Agree nor disagree"
	replace `var'2 = 3 if `var' == "Disagree"
	replace `var'2 = 4 if `var' == "Strongly disagree"
	replace `var'2 = 4 if `var' == "Strongly Disagree"
}
*
alpha q119_12-q119_72, gen(postLegitControl)

order q64-q83, last

*** remaining treatments
foreach var of varlist q123-q155{
	gen `var'2 = .
	replace `var'2 = 0 if `var' == "Strongly agree"
	replace `var'2 = 0 if `var' == "Strongly Agree"
	replace `var'2 = 1 if `var' == "Agree"
	replace `var'2 = 2 if `var' == "Neither agree nor disagree"
	replace `var'2 = 2 if `var' == "Neither Agree nor disagree"
	replace `var'2 = 3 if `var' == "Disagree"
	replace `var'2 = 4 if `var' == "Strongly disagree"
	replace `var'2 = 4 if `var' == "Strongly Disagree"
}
*
sum
*** 
alpha q1232-q1352, gen(postOreilly)
alpha q1412-q1472, gen(postSchumer)
alpha bt2-bz2, gen(postCooper)
alpha ca2-q1392, gen(postMaddow)
alpha q1172-cn2, gen(postRomney)
alpha q1492-q1552, gen(postLimbaugh)



**** post politicization
foreach var of varlist q137_1-q137_3{
	gen `var'2 = .
	replace `var'2 = 4 if `var' == "Strongly agree"
	replace `var'2 = 4 if `var' == "Strongly Agree"
	replace `var'2 = 3 if `var' == "Agree"
	replace `var'2 = 2 if `var' == "Neither agree nor disagree"
	replace `var'2 = 2 if `var' == "Neither Agree nor disagree"
	replace `var'2 = 1 if `var' == "Disagree"
	replace `var'2 = 0 if `var' == "Strongly disagree"
	replace `var'2 = 0 if `var' == "Strongly Disagree"
}
*
alpha q137_12-q137_32, gen(postPolit)


*** post SC ideo 
 
gen postSCideo = . 
replace postSC = 1 if cz == "Very liberal"
replace postSC = 2 if cz == "Somewhat liberal"
replace postSC = 3 if cz == "Moderate"
replace postSC = 4 if cz == "Somewhat conservative"
replace postSC = 5 if cz == "Very conservative"


****************
*** pre-treatment ideological difference
****************

gen preIdeoDiff = .
replace preIdeo = 0 if ideo5 == 1 & preSC == 1
replace preIdeo = 0 if ideo5 == 2 & preSC == 2
replace preIdeo = 0 if ideo5 == 3 & preSC == 3
replace preIdeo = 0 if ideo5 == 4 & preSC == 4
replace preIdeo = 0 if ideo5 == 5 & preSC == 5

replace preIdeo = 1 if ideo5 == 1 & preSC == 2
replace preIdeo = 1 if ideo5 == 2 & preSC == 1
replace preIdeo = 1 if ideo5 == 2 & preSC == 3
replace preIdeo = 1 if ideo5 == 3 & preSC == 2
replace preIdeo = 1 if ideo5 == 3 & preSC == 4
replace preIdeo = 1 if ideo5 == 4 & preSC == 3
replace preIdeo = 1 if ideo5 == 4 & preSC == 5
replace preIdeo = 1 if ideo5 == 5 & preSC == 4

replace preIdeo = 2 if ideo5 == 1 & preSC == 3
replace preIdeo = 2 if ideo5 == 2 & preSC == 4
replace preIdeo = 2 if ideo5 == 3 & preSC == 1
replace preIdeo = 2 if ideo5 == 3 & preSC == 5
replace preIdeo = 2 if ideo5 == 4 & preSC == 2
replace preIdeo = 2 if ideo5 == 5 & preSC == 3

replace preIdeo = 3 if ideo5 == 1 & preSC == 4
replace preIdeo = 3 if ideo5 == 2 & preSC == 5
replace preIdeo = 3 if ideo5 == 4 & preSC == 1
replace preIdeo = 3 if ideo5 == 5 & preSC == 2

replace preIdeo = 4 if ideo5 == 1 & preSC == 5
replace preIdeo = 4 if ideo5 == 5 & preSC == 1

****************
*** post-treatment ideological difference
****************

gen postIdeoDiff = .
replace postIdeo = 0 if ideo5 == 1 & postSC == 1
replace postIdeo = 0 if ideo5 == 2 & postSC == 2
replace postIdeo = 0 if ideo5 == 3 & postSC == 3
replace postIdeo = 0 if ideo5 == 4 & postSC == 4
replace postIdeo = 0 if ideo5 == 5 & postSC == 5

replace postIdeo = 1 if ideo5 == 1 & postSC == 2
replace postIdeo = 1 if ideo5 == 2 & postSC == 1
replace postIdeo = 1 if ideo5 == 2 & postSC == 3
replace postIdeo = 1 if ideo5 == 3 & postSC == 2
replace postIdeo = 1 if ideo5 == 3 & postSC == 4
replace postIdeo = 1 if ideo5 == 4 & postSC == 3
replace postIdeo = 1 if ideo5 == 4 & postSC == 5
replace postIdeo = 1 if ideo5 == 5 & postSC == 4

replace postIdeo = 2 if ideo5 == 1 & postSC == 3
replace postIdeo = 2 if ideo5 == 2 & postSC == 4
replace postIdeo = 2 if ideo5 == 3 & postSC == 1
replace postIdeo = 2 if ideo5 == 3 & postSC == 5
replace postIdeo = 2 if ideo5 == 4 & postSC == 2
replace postIdeo = 2 if ideo5 == 5 & postSC == 3

replace postIdeo = 3 if ideo5 == 1 & postSC == 4
replace postIdeo = 3 if ideo5 == 2 & postSC == 5
replace postIdeo = 3 if ideo5 == 4 & postSC == 1
replace postIdeo = 3 if ideo5 == 5 & postSC == 2

replace postIdeo = 4 if ideo5 == 1 & postSC == 5
replace postIdeo = 4 if ideo5 == 5 & postSC == 1

****************
*** change in ideological difference
*** (post-pre) such that positive values 
*** indicate distance has GROWN 
*****************
gen ideoDiff = postIdeo - preIdeo


**************
**** ordinalize feeling therms
**************

foreach var of varlist romney-limbaugh{
	gen `var'2 = .
	replace `var'2 = 1 if `var' >= 0 & `var' < 10
	replace `var'2 = 2 if `var' >= 10 & `var' < 20
	replace `var'2 = 3 if `var' >= 20 & `var' < 30
	replace `var'2 = 4 if `var' >= 30 & `var' < 40
	replace `var'2 = 5 if `var' >= 40 & `var' < 50
	replace `var'2 = 6 if `var' >= 50 & `var' < 60
	replace `var'2 = 7 if `var' >= 60 & `var' < 70
	replace `var'2 = 8 if `var' >= 70 & `var' < 80
	replace `var'2 = 9 if `var' >= 80 & `var' < 90
	replace `var'2 = 10 if `var' >= 90 & `var' < 101
}
*



*******************************************
*******************************************
* generate difference in legitimacy
* (post - pre) such that higher values indicate 
* increased levels of support
*******************************************
*******************************************

gen controlDiff = postLegitControl - preLegit 
reg controlDiff

gen oreillyDiff = postOreilly - preLegit 
reg controlDiff oreilly2 
reg oreillyDiff oreilly2 ideoDiff pid
margins, at(oreilly= (1(1)10))

quietly reg oreillyDiff oreilly2 ideoDiff
margins, at(ideoDiff= (-3(1)4))


gen schumerDiff = postSchumer - preLegit
reg schumerDiff schumer2 ideoDiff 
reg controlDiff schumer2
margins, at(schumer = (1(1)10))

quietly reg schumerDiff schumer2 ideoDiff
margins, at(ideoDiff= (-3(1)4))


gen cooperDiff = postCooper - preLegit
reg cooperDiff cooper2 ideoDiff 
reg controlDiff cooper2
margins, at(cooper = (1(1)10))

quietly reg cooperDiff cooper2 ideoDiff
margins, at(ideoDiff= (-3(1)4))


gen maddowDiff = postMaddow - preLegit
reg maddowDiff maddow2 ideoDiff
reg controlDiff maddow2
margins, at(maddow = (1(1)10))

quietly reg maddowDiff maddow2 ideoDiff
margins, at(ideoDiff= (-3(1)4))


gen romneyDiff = postRomney - preLegit
reg romneyDiff romney2 ideoDiff
reg controlDiff romney2
margins, at(romney = (1(1)10))

quietly reg romneyDiff romney2 ideoDiff
margins, at(ideoDiff= (-3(1)4))


gen limbaughDiff = postLimbaugh - preLegit
reg limbaughDiff limbaugh2 ideoDiff
reg controlDiff limbaugh2
margins, at(limbaugh= (1(1)10))

reg limbaughDiff limbaugh2 ideoDiff
margins, at(ideoDiff= (-3(1)4))


*** robustness checks; altering specification

egen totalDiff = rowmean(controlD oreillyD schumerD cooperD maddowD romneyD limbaughD)


gen treat = .
replace treat = 0 if controlDiff != .
replace treat = 1 if oreillyD != .
replace treat = 2 if schumerD != .
replace treat = 3 if cooperD != .
replace treat = 4 if maddowD != .
replace treat = 5 if romneyD != .
replace treat = 6 if limbaughD != .

*** here, total affect is the affect toward the experimental source cue
*** so, control group people are omitted. 


gen totalAffect = .
replace totalAffect = oreilly2 if oreillyD != .
replace totalAffect = schumer2  if schumerD != .
replace totalAffect = cooper2 if cooperD != .
replace totalAffect = maddow2 if maddowD != .
replace totalAffect = romney2 if romneyD != .
replace totalAffect = limbaugh2 if limbaughD != .


* clustered standard errors
reg totalDiff totalAffect ideoDiff, cluster(treat)

* mixed effects model where treatment is the level
mixed totalDiff totalAffect ideoDiff || treat: 

* mixed effects model where individual is the level and  treatment is the random effect
gen id = _n

mixed totalDiff totalAffect ideoDiff || id: R.treat, covariance(identity) 

* fixed effects model 

xtset treat
xtreg totalDiff totalAffect ideoDiff, fe

* random effects model

xtreg totalDiff totalAffect ideoDiff, re




**************************
**************************l
keep romney2-limbaugh2
saveold "for densities.dta", version(12) replace

**************************
**************************
keep controlDiff oreillyDiff-limbaughDiff
saveold "for densities2.dta", version(12) replace


save "kst.dta", replace

***************** kolmogorov-smirnov tests
use "kst.dta", clear
keep controlDiff oreillyDiff
stack controlDiff oreillyDiff, into(group)
ksmirnov group, by(_stack) exact

use "kst.dta", clear
keep controlDiff romneyDiff
stack controlDiff romneyDiff, into(group)
ksmirnov group, by(_stack) exact

use "kst.dta", clear
keep controlDiff maddowDiff
stack controlDiff maddowDiff, into(group)
ksmirnov group, by(_stack) exact

use "kst.dta", clear
keep controlDiff cooperDiff
stack controlDiff cooperDiff, into(group)
ksmirnov group, by(_stack) exact

use "kst.dta", clear
keep controlDiff limbaughDiff
stack controlDiff limbaughDiff, into(group)
ksmirnov group, by(_stack) exact

use "kst.dta", clear
keep controlDiff schumerDiff
stack controlDiff schumerDiff, into(group)
ksmirnov group, by(_stack) exact



**********************************
***** demographics for appendices 
**********************************

use "kst.dta", clear

gen female = .
replace female = 0 if q64 == "Male"
replace female = 1 if q64 == "Female"

gen race = .
replace race = 1 if q66 == "White, non-Hispanic"
replace race = 2 if q66 == "Black, non-Hispanic"
replace race = 3 if q66 == "Hispanic"
replace race = 4 if q66 == "Other, non-Hispanic" 

label define race ///
	1 "White" ///
	2 "Black" ///
	3 "Hispanic" ///
	4 "Other"
label values race race

gen education = .
replace education = 0 if q70 == "Did no graduate high school"
replace education = 1 if q70 == "High school diploma or equivalent (GED)"
replace education = 2 if q70 == "Some college but no degree"
replace education = 3 if q70 == "Bachelor's degree (BA, MS, BSW, etc.)"
replace education = 4 if q70 == "Graduate degree (MA, MS, MSW, MD, PhD, etc.)"

gen income = .
replace income = 0 if q78 == "Less than $10,000" 
replace income = 1 if q78 == "$10,000 - $19,999"
replace income = 2 if q78 == "$20,000 - $29,999"
replace income = 3 if q78 == "$30,000 - $39,999"
replace income = 4 if q78 == "$40,000 - $49,999"
replace income = 5 if q78 == "$50,000 - $59,999"
replace income = 6 if q78 == "$60,000 - $69,999"
replace income = 7 if q78 == "$70,000 - $79,999"
replace income = 8 if q78 == "$80,000 - $89,999"
replace income = 9 if q78 == "$90,000 - $99,999"
replace income = 10 if q78 == "$100,000 - $149,999"
replace income = 11 if q78 == "More than $150,000"


gen treatment = .
replace treatment = 0 if controlDiff != .
replace treatment = 1 if cooperDiff != .
replace treatment = 2 if limbaughDiff != .
replace treatment = 3 if maddowDiff != .
replace treatment = 4 if oreillyDiff != .
replace treatment = 5 if romneyDiff != .
replace treatment = 6 if schumerDiff != .

label define treatment ///
	0 "Control" ///
	1 "Cooper" ///
	2 "Limbaugh" ///
	3 "Maddow" ///
	4 "O'Reilly" ///
	5 "Romney" ///
	6 "Schumer" 
label values treatment treatment

